package br.com.fatecpg.operon.frames;

import br.com.fatecpg.operon.Conexao;
import java.sql.SQLDataException;
import java.sql.SQLException;
import javax.swing.JOptionPane;

public class HorariosdeaulaJInternalFrame extends javax.swing.JInternalFrame {

    public static void main(String[] args) {


    }

    /** Creates new form HorariosdeaulaJInternalFrame */
    public HorariosdeaulaJInternalFrame() {
        initComponents();
    }
int cod = 0;
      @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        CodHorajLabel = new javax.swing.JLabel();
        DiajComboBox = new javax.swing.JComboBox();
        HorariojComboBox = new javax.swing.JComboBox();
        Button_Adicionar = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();

        setClosable(true);
        setIconifiable(true);
        setMaximizable(true);
        setTitle("Horários de Aula");
        getContentPane().setLayout(null);

        jLabel1.setFont(new java.awt.Font("Verdana", 3, 24));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Horários de Aula");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(10, 11, 513, 30);

        jLabel2.setFont(new java.awt.Font("Verdana", 1, 14));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Cod do Horário:");
        getContentPane().add(jLabel2);
        jLabel2.setBounds(10, 62, 125, 18);

        jLabel3.setFont(new java.awt.Font("Verdana", 1, 14));
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Dia da Semana:");
        getContentPane().add(jLabel3);
        jLabel3.setBounds(10, 110, 125, 18);

        jLabel4.setFont(new java.awt.Font("Verdana", 1, 14));
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("Horário:");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(10, 150, 125, 18);

        CodHorajLabel.setFont(new java.awt.Font("Verdana", 1, 14));
        CodHorajLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        CodHorajLabel.setText("  ");
        CodHorajLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        getContentPane().add(CodHorajLabel);
        CodHorajLabel.setBounds(141, 59, 382, 25);

        DiajComboBox.setFont(new java.awt.Font("Verdana", 1, 14));
        DiajComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione ...", "Segunda Feira", "Terça Feira", "Quarta Feira", "Quita Feira", "Sexta Feira", "Sabado", "Domingo" }));
        getContentPane().add(DiajComboBox);
        DiajComboBox.setBounds(141, 102, 382, 24);

        HorariojComboBox.setFont(new java.awt.Font("Verdana", 1, 14));
        HorariojComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione ...", "00:00:00", "01:00:00", "02:00:00", "03:00:00", "04:00:00", "05:00:00", "06:00:00", "07:00:00", "08:00:00", "09:00:00", "10:00:00", "11:00:00", "12:00:00", "13:00:00", "14:00:00", "15:00:00", "16:00:00", "17:00:00", "18:00:00", "19:00:00", "20:00:00", "21:00:00", "22:00:00", "23:00:00" }));
        getContentPane().add(HorariojComboBox);
        HorariojComboBox.setBounds(141, 146, 382, 24);

        Button_Adicionar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/fatecpg/operon/icons/48px-Crystal_Clear_action_edit_add.png"))); // NOI18N
        Button_Adicionar.setToolTipText("Cadastrar Horário de Aula");
        Button_Adicionar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button_AdicionarActionPerformed(evt);
            }
        });
        getContentPane().add(Button_Adicionar);
        Button_Adicionar.setBounds(10, 200, 60, 60);

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/fatecpg/operon/imagens/escola_1024x768.jpg"))); // NOI18N
        jLabel5.setText(" ");
        getContentPane().add(jLabel5);
        jLabel5.setBounds(-200, -100, 920, 450);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-647)/2, (screenSize.height-381)/2, 647, 381);
    }// </editor-fold>//GEN-END:initComponents

    private void Button_AdicionarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button_AdicionarActionPerformed

        cod = cod ++;
        CodHorajLabel.setText(""+ cod);


        String codigo = CodHorajLabel.getText();
        String dia = DiajComboBox.getToolTipText();
        String hora = HorariojComboBox.getToolTipText();

        String SQL="INSERT INTO HORARIOS_DE_AULA VALUES" + "("+codigo+")"+ "("+dia+")"+ "("+hora+")";

       try{
           Conexao.con.createStatement().executeQuery(SQL);
           this.dispose();

        }catch (SQLException ex){
            JOptionPane.showMessageDialog(this, "0 registro não pode ser inserido. Erro: "+ex.getMessage(),"Erro",JOptionPane.ERROR_MESSAGE);
        }

}//GEN-LAST:event_Button_AdicionarActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Button_Adicionar;
    private javax.swing.JLabel CodHorajLabel;
    private javax.swing.JComboBox DiajComboBox;
    private javax.swing.JComboBox HorariojComboBox;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    // End of variables declaration//GEN-END:variables
}
